home *** CD-ROM | disk | FTP | other *** search
/ Champak 54 / Vol 54.iso / games / zman.swf / scripts / frame_4 / DoAction.as
Encoding:
Text File  |  2007-10-01  |  8.7 KB  |  305 lines

  1. this.stop();
  2. FNscore = function(s, num)
  3. {
  4.    var _loc2_ = 1;
  5.    while(_loc2_ <= 7)
  6.    {
  7.       this.menu_mc[s + _loc2_].gotoAndStop(Math.floor(num / Math.pow(10,_loc2_ - 1)) % 10 + 1);
  8.       _loc2_ = _loc2_ + 1;
  9.    }
  10. };
  11. FNimg = function()
  12. {
  13.    img = new Array();
  14.    var _loc1_ = 0;
  15.    while(_loc1_ <= 19)
  16.    {
  17.       if(_loc1_ < 11)
  18.       {
  19.          img[_loc1_] = _loc1_ + 1;
  20.       }
  21.       else
  22.       {
  23.          img[_loc1_] = _loc1_ - 11;
  24.       }
  25.       _loc1_ = _loc1_ + 1;
  26.    }
  27.    _loc1_ = 0;
  28.    while(_loc1_ < 50)
  29.    {
  30.       var _loc3_ = random(20);
  31.       var _loc2_ = random(20);
  32.       var _loc4_ = img[_loc3_];
  33.       img[_loc3_] = img[_loc2_];
  34.       img[_loc2_] = _loc4_;
  35.       _loc1_ = _loc1_ + 1;
  36.    }
  37.    trace(img);
  38.    img[19] = 1;
  39. };
  40. FNimg();
  41. FNchogi = function()
  42. {
  43.    game_ok = false;
  44.    level = 1;
  45.    FNscore("l",level);
  46.    score = 0;
  47.    FNscore("s",score);
  48.    life = 4;
  49.    this.menu_mc.life.gotoAndStop(life);
  50.    mission = 10;
  51.    FNscore("m",mission);
  52.    current = 0;
  53.    FNscore("c",current);
  54.    speed = 30 - (level - 1);
  55.    time = 15;
  56.    add_time = 0;
  57.    duplicate_time = 80 - (level - 1) * 5;
  58.    player_depths = this.player.getDepth();
  59.    text_depths = this.text_mc.getDepth();
  60.    menu_depths = this.menu_mc.getDepth();
  61.    stop_depths = this.stop_window.getDepth();
  62.    link_depths = this.link_mc.getDepth();
  63.    this.text_mc.swapDepths(22);
  64.    this.menu_mc.swapDepths(23);
  65.    this.stop_window.swapDepths(24);
  66.    this.link_mc.swapDepths(25);
  67.    this.text_mc.gotoAndStop("start");
  68.    this.game_controler._visible = false;
  69. };
  70. FNchogi();
  71. FNlevelup = function()
  72. {
  73.    level++;
  74.    FNscore("l",level);
  75.    current = 0;
  76.    FNscore("c",current);
  77.    if(level < 11)
  78.    {
  79.       speed = 30 - (level - 1);
  80.       duplicate_time = 80 - (level - 1) * 5;
  81.    }
  82.    else
  83.    {
  84.       speed = 20;
  85.       duplicate_time = 30;
  86.    }
  87.    add_time = 0;
  88.    FNclear();
  89.    this.player.swapDepths(player_depths);
  90.    this.player.gotoAndStop(1);
  91. };
  92. FNclear = function()
  93. {
  94.    var _loc2_ = 1;
  95.    while(_loc2_ <= 20)
  96.    {
  97.       this["people" + _loc2_].gotoAndStop("clear");
  98.       _loc2_ = _loc2_ + 1;
  99.    }
  100. };
  101. FNgameover = function()
  102. {
  103.    FNclear();
  104.    this.text_mc.swapDepths(text_depths);
  105.    this.menu_mc.swapDepths(menu_depths);
  106.    this.stop_window.swapDepths(stop_depths);
  107.    this.link_mc.swapDepths(link_depths);
  108. };
  109. people_depths = 20;
  110. FNpeople = function()
  111. {
  112.    trace("duplicate");
  113.    this.people_mc.duplicateMovieClip("people" + people_depths,people_depths);
  114.    this["people" + people_depths]._x = 1;
  115.    this["people" + people_depths]._y = 15;
  116.    this["people" + people_depths].mc.gotoAndStop(img[people_depths - 1]);
  117.    if(people_depths % 3 == 1)
  118.    {
  119.       this["people" + people_depths].mc.item.gotoAndStop(random(4) + 2);
  120.    }
  121.    this["people" + people_depths].move = true;
  122.    this["people" + people_depths].talk = false;
  123.    this["people" + people_depths].time = speed;
  124.    this["people" + people_depths].move_i = 0;
  125.    this["people" + people_depths].fall_ok = false;
  126.    this["people" + people_depths].hit_ok = true;
  127.    this["people" + people_depths].onEnterFrame = function()
  128.    {
  129.       if(_root.game_ok)
  130.       {
  131.          if(this.move)
  132.          {
  133.             this.move_i = this.move_i + 1;
  134.             if(this.fall_ok)
  135.             {
  136.                this.mc.m.gotoAndStop(2);
  137.                if(this.hitTest(_root.player.hit) && this.hit_ok)
  138.                {
  139.                   this.hit_ok = false;
  140.                   if(this.mc.item._currentframe < 5)
  141.                   {
  142.                      if(this.mc.item._currentframe != 1)
  143.                      {
  144.                         if(this.mc.item._currentframe == 2)
  145.                         {
  146.                            if(_root.life < 4)
  147.                            {
  148.                               _root.life = _root.life + 1;
  149.                            }
  150.                            _root.menu_mc.life.gotoAndStop(_root.life);
  151.                         }
  152.                         else if(this.mc.item._currentframe == 3)
  153.                         {
  154.                            _root.add_time += 10;
  155.                            speed += _root.add_time;
  156.                         }
  157.                         else if(this.mc.item._currentframe == 4)
  158.                         {
  159.                            _root.rail_mc.gotoAndStop("ran");
  160.                         }
  161.                      }
  162.                      this.move_i = 0;
  163.                      this.fall_ok = false;
  164.                      this.talk = true;
  165.                      this.mc.m.gotoAndStop(1);
  166.                      this.hit_ok = true;
  167.                      this.nextFrame();
  168.                      _root.score += 3;
  169.                      _root.FNscore("s",score);
  170.                   }
  171.                   else
  172.                   {
  173.                      _root.life = _root.life - 1;
  174.                      _root.menu_mc.life.gotoAndStop(_root.life);
  175.                      if(_root.life == 1)
  176.                      {
  177.                         _root.game_ok = false;
  178.                         _root.game_controler._visible = false;
  179.                         _root.text_mc.gotoAndStop("gameover");
  180.                      }
  181.                      this.move = false;
  182.                      this.mc.gotoAndStop(this.mc._currentframe + 12);
  183.                   }
  184.                   this.mc.item.m.nextFrame();
  185.                }
  186.                else if(this.move_i % _root.time == 0)
  187.                {
  188.                   if(this.mc.item._currentframe != 5)
  189.                   {
  190.                      if(Math.ceil(this._currentframe / 5) + 1 != _root.rail_mc._currentframe)
  191.                      {
  192.                         _root.life = _root.life - 1;
  193.                         _root.menu_mc.life.gotoAndStop(_root.life);
  194.                         if(_root.life == 1)
  195.                         {
  196.                            _root.game_ok = false;
  197.                            _root.game_controler._visible = false;
  198.                            _root.text_mc.gotoAndStop("gameover");
  199.                         }
  200.                         this.move = false;
  201.                         this.mc.m.gotoAndStop(3);
  202.                      }
  203.                      else if(this.hitTest(_root.rail_mc.hit))
  204.                      {
  205.                         _root.rail_mc.gotoAndStop(1);
  206.                         this.move_i = 0;
  207.                         this.fall_ok = false;
  208.                         this.mc.m.gotoAndStop(1);
  209.                         this.hit_ok = true;
  210.                         this.nextFrame();
  211.                      }
  212.                   }
  213.                   else
  214.                   {
  215.                      this.move_i = 0;
  216.                      this.fall_ok = false;
  217.                      this.mc.m.gotoAndStop(1);
  218.                      this.hit_ok = true;
  219.                      this.nextFrame();
  220.                   }
  221.                }
  222.             }
  223.             else if(this.move_i % (this.time + _root.add_time) == 0)
  224.             {
  225.                this.move_i = 0;
  226.                this.fall_ok = false;
  227.                this.nextFrame();
  228.             }
  229.          }
  230.       }
  231.    };
  232.    if(people_depths > 1)
  233.    {
  234.       people_depths--;
  235.    }
  236.    else
  237.    {
  238.       FNimg();
  239.       people_depths = 20;
  240.    }
  241. };
  242. FNplayer = function()
  243. {
  244.    if(Key.isDown(38))
  245.    {
  246.       if(this.player._currentframe == 3 && this.rail_mc._currentframe != 3)
  247.       {
  248.          this.player.gotoAndStop(2);
  249.       }
  250.       else if(this.player._currentframe == 4 && this.rail_mc._currentframe != 2)
  251.       {
  252.          this.player.gotoAndStop(1);
  253.       }
  254.    }
  255.    if(Key.isDown(40))
  256.    {
  257.       if(this.player._currentframe == 1 && this.rail_mc._currentframe != 5)
  258.       {
  259.          this.player.gotoAndStop(4);
  260.       }
  261.       else if(this.player._currentframe == 2 && this.rail_mc._currentframe != 4)
  262.       {
  263.          this.player.gotoAndStop(3);
  264.       }
  265.    }
  266.    if(Key.isDown(39))
  267.    {
  268.       if(this.player._currentframe == 1 && this.rail_mc._currentframe != 3)
  269.       {
  270.          this.player.gotoAndStop(2);
  271.       }
  272.       else if(this.player._currentframe == 4 && this.rail_mc._currentframe != 4)
  273.       {
  274.          this.player.gotoAndStop(3);
  275.       }
  276.    }
  277.    if(Key.isDown(37))
  278.    {
  279.       if(this.player._currentframe == 2 && this.rail_mc._currentframe != 2)
  280.       {
  281.          this.player.gotoAndStop(1);
  282.       }
  283.       else if(this.player._currentframe == 3 && this.rail_mc._currentframe != 5)
  284.       {
  285.          this.player.gotoAndStop(4);
  286.       }
  287.    }
  288. };
  289. duplicate_i = 0;
  290. duplicate_random = 72;
  291. this.onEnterFrame = function()
  292. {
  293.    if(game_ok)
  294.    {
  295.       duplicate_i++;
  296.       if(duplicate_i % (duplicate_random + add_time * 4) == 0)
  297.       {
  298.          duplicate_i = 0;
  299.          duplicate_random = duplicate_time + random(50);
  300.          FNpeople();
  301.       }
  302.       FNplayer();
  303.    }
  304. };
  305.